<?php
global $references;
$references = array(

	"type.commerce.Category" => array(
		"class" => "Pageley_Domain_BasicType",
		"constructor" => array(
			"namespace" => "#{commerceNamespace}",
			"name" => "Category"
		),
		"properties" => array(
			"attributes" => array(
				"name" => "#{attribute.required(attribute.name)}",
				"description" => "#{attribute.text}",
				"parentCategory" => "#{attribute.commerce.category}",
                "articles" => "#{attribute.oneToMany(attribute.commerce.article)}",
                "categories" => "#{attribute.oneToMany(attribute.commerce.category)}"
			),
			"className" => "Pageley_Commerce_Domain_Category"
		)
	),

	"type.commerce.Article" => array(
		"class" => "Pageley_Domain_BasicType",
		"constructor" => array(
			"namespace" => "#{commerceNamespace}",
			"name" => "Article"
		),
		"properties" => array(
            "attributes" => array(
                "name" => "#{attribute.required(attribute.name)}",
                "description" => "#{attribute.text}",
                "category" => "#{attribute.required(attribute.commerce.category)}",
                "price" => "#{attribute.required(attribute.money)}",
                "supplier" => "#{attribute.required(attribute.commerce.supplier)}",
                "date" => "#{attribute.required(attribute.timestamp)}",
                "active" => "#{attribute.required(attribute.boolean)}",
                "image" => "#{attribute.image}" // TODO: provide image attribute
            ),
            "className" => "Pageley_Commerce_Domain_Article"
		)
	),
    
	"type.commerce.Supplier" => array(
		"class" => "Pageley_Domain_BasicType",
		"constructor" => array(
			"namespace" => "#{commerceNamespace}",
			"name" => "Supplier"
		),
		"properties" => array(
		  "attributes" => array(
                "code" => "#{attribute.unique(attribute.code)}",
                "companyName" => "#{attribute.required(attribute.name)}",
                "address" => "#{attribute.required(attribute.address)}",
                "vatCode" => "#{attribute.required(attribute.code)}",
                "emailAddress" => "#{attribute.required(attribute.emailAddress)}",
                "websiteUrl" => "#{attribute.url}",
                "phoneNumber" => "#{attribute.phoneNumber}",
                "faxNumber" => "#{attribute.phoneNumber}",
                "mobileNumber" => "#{attribute.phoneNumber}"
            ),
            "className" => "Pageley_Commerce_Domain_Supplier"
		)
	),

	"type.commerce.Customer" => array(
		"class" => "Pageley_Domain_BasicType",
		"constructor" => array(
			"namespace" => "#{commerceNamespace}",
			"name" => "Customer"
		),
		"properties" => array(
            "attributes" => array(
                "contactName" => "#{attribute.required(attribute.name)}",
                "username" => "#{attribute.unique(attribute.name)}",
                "password" => "#{attribute.required(attribute.password)}",
                "address" => "#{attribute.required(attribute.address)}",
                "emailAddress" => "#{attribute.unique(attribute.emailAddress)}",
                "phoneNumber" => "#{attribute.phoneNumber}",
                "faxNumber" => "#{attribute.phoneNumber}",
                "mobileNumber" => "#{attribute.phoneNumber}",
                "passwordExpiryDate" => "#{attribute.timestamp}",
                "passwordExpiryInterval" => "#{attribute.number}",
                "companyName" => "#{attribute.name}",
                "vatCode" => "#{attribute.code}",
		        "status" => "#{attribute.required(attribute.commerce.customerStatus)}",
                "orders" => "#{attribute.oneToMany(attribute.commerce.order)}"
            ),
            "className" => "Pageley_Commerce_Domain_Customer"
		)
	),

	"type.commerce.Order" => array(
		"class" => "Pageley_Domain_BasicType",
		"constructor" => array(
			"namespace" => "#{commerceNamespace}",
			"name" => "Order"
		),
		"properties" => array(
            "attributes" => array(
                "customer" => "#{attribute.commerce.customer}",
                "datePlaced" => "#{attribute.timestamp}",
                "status" => "#{attribute.commerce.orderStatus}",
                "paymentMethod" => "#{attribute.required(attribute.commerce.paymentMethod)}",
                "amountPayed" => "#{attribute.money}",
                "comment" => "#{attribute.text}",
                "sendInvoice" => "#{attribute.required(attribute.boolean)}",
                "ipAddress" => "#{attribute.code}",
                "billingName" => "#{attribute.required(attribute.name)}",
                "billingAddress" => "#{attribute.required(attribute.address)}",
                "billingEmailAddress" => "#{attribute.required(attribute.emailAddress)}",
                "vatCode" => "#{attribute.code}",
                "deliveryName" => "#{attribute.required(attribute.name)}",
		        "deliveryAddress" => "#{attribute.required(attribute.address)}",
                "orderItems" => "#{attribute.oneToMany(attribute.commerce.orderItem)}"
            ),
            "className" => "Pageley_Commerce_Domain_Order"
   		)
	),

	"type.commerce.OrderItem" => array(
		"class" => "Pageley_Domain_BasicType",
		"constructor" => array(
			"namespace" => "#{commerceNamespace}",
			"name" => "OrderItem"
		),
		"properties" => array(
		  "attributes" => array(
                "article" => "#{attribute.required(attribute.commerce.article)}",
                "order" => "#{attribute.required(attribute.commerce.order)}",
                "quantity" => "#{attribute.required(attribute.positiveInteger)}",
                "price" => "#{attribute.required(attribute.money)}"
            ),
            "className" => "Pageley_Commerce_Domain_OrderItem"
        )
	)
);